﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using InterfaceComponents;
using GlobalGameClasses;
using Sirian;
using Serialization;
using Serialization.Script;
using WorldView;
using DrawableObjects.Actors.Aircrafts;
using DrawableObjects.Actors.Weapons;
using DrawableObjects.Actors.Aircrafts.Controller;
using DrawableObjects.Actors;
using DrawableObjects;
using LightEffects;

namespace Modes
{
    /// <summary>
    /// The ModeFactory class provides methods to create new instances of each mode.
    /// </summary>
    class ModeFactory
    {

        private SirianGame game;

        public ModeFactory(SirianGame game)
        {
            this.game = game;
        }

        public MenuMode createMainMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("startGame");
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 2 * font.LineSpacing - 2 * 20);
            Button button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Difficulty, SirianGame.Modes.Main);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("options");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 1 * font.LineSpacing - 1 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Option, SirianGame.Modes.Main);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("highscore");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 0 * font.LineSpacing - 0 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Highscore, SirianGame.Modes.Main);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("achievements");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + 1 * font.LineSpacing + 1 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Achievement, SirianGame.Modes.Main);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("controls");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + 2 * font.LineSpacing + 2 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Control, SirianGame.Modes.Main);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("endGame");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + 3 * font.LineSpacing + 3 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Exit, SirianGame.Modes.Main);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public StartMode createStartMode(Video video)
        {
            return new StartMode(video, game.spriteBatch);
        }

        public MenuMode createLoginMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("accName") + ":";
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - font.LineSpacing - 0.5f * 20);
            Label label = new Label(text, pos, game.spriteBatch, font);
            components.Add(label);
            int maxinput = 25;
            size = new Vector2(font.MeasureString("Ö").X * maxinput, size.Y);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + font.LineSpacing + 0.5f * 20);
            TextBox textbox = new TextBox(maxinput, pos, game.spriteBatch, font);
            textbox.confirmInput += new GlobalGameClasses.Eventhandler.ConfirmLogin(game.OnConfirmLogin);
            components.Add(textbox);
            return new MenuMode(background, components, Color.White, Color.White, game.spriteBatch);
        }

        public MenuMode createOptionsMenu(Texture2D background, SpriteFont font, SirianGame.Modes next, SirianGame.Modes parent)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("musicVolume") + ": ";
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X, 315 - size.Y / 2f - 2 * font.LineSpacing - 2 * 20);
            Label label = new Label(text, pos, game.spriteBatch, font);
            components.Add(label);
            pos = new Vector2(560, 315 - size.Y / 2f - 2 * font.LineSpacing - 2 * 20);
            Slider slider = new Slider(GlobalGameClasses.GlobalGameValues.Values.volume_Music, pos, game.spriteBatch, font, SirianGame.Volume.Music);
            components.Add(slider);
            text = GlobalGameValues.Values.GlobalStrings.getValue("soundVolume") + ": ";
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X, 315 - size.Y / 2f - 1 * font.LineSpacing - 1 * 20);
            label = new Label(text, pos, game.spriteBatch, font);
            components.Add(label);
            pos = new Vector2(560, 315 - size.Y / 2f - 1 * font.LineSpacing - 1 * 20);
            slider = new Slider(GlobalGameClasses.GlobalGameValues.Values.volume_soundEffect, pos, game.spriteBatch, font, SirianGame.Volume.Sound);
            components.Add(slider);
            text = GlobalGameValues.Values.GlobalStrings.getValue("back");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + 1 * font.LineSpacing + 1 * 20);
            Button button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, next, parent);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public MenuMode createControlsMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("back");
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X / 2f, 580);
            Button button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Main, SirianGame.Modes.Control);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public MenuMode createHighscoreMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            for (int i = -5; i < 5; i++)
            {
                HighscoreEntry current;
                if (i + 5 < game.highscore.Count)
                {
                    current = game.highscore[i + 5];
                }
                else
                {
                    current = new HighscoreEntry(new Account("???"), 0);
                }
                Vector2 size = font.MeasureString(current.account.name + "    ");
                Vector2 pos = new Vector2(560 - size.X, 355 - size.Y / 2f + i * font.LineSpacing + i * 20);
                Label label = new Label(current.account.name + "    ", pos, game.spriteBatch, font);
                components.Add(label);
                pos = new Vector2(560, 355 - size.Y / 2f + i * font.LineSpacing + i * 20);
                label = new Label(current.score.ToString(), pos, game.spriteBatch, font);
                components.Add(label);
            }
            string text = GlobalGameValues.Values.GlobalStrings.getValue("back");
            Vector2 sizeB = font.MeasureString(text);
            Vector2 posB = new Vector2(560 - sizeB.X / 2f, 580);
            Button button = new Button(new Rectangle((int)posB.X - 5, (int)posB.Y - 5, (int)sizeB.X + 10, (int)sizeB.Y + 10), text, posB, game.spriteBatch, font, SirianGame.Modes.Main, SirianGame.Modes.Highscore);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public GameMode createGameMode()
        {
            //Sets the progress value of the terrain to zero to indicate which terrain part should be drawn
            game.terrain.RestartTerrain();
            ScriptReader reader = new ScriptReader(game.LEVELSCRIPT_PATH);
            LevelScript script = reader.readLevelScript(GlobalGameValues.Values.errorWriter);
            game.acHandler = new AchievementHandler(script.getNumberOfEnemies(), game.currentAccount.name);
            GenericDrawableList drawableList = new GenericDrawableList();

            List<InterfaceComponent> HUD = new List<InterfaceComponent>();
            SpriteFont font;
            if (!GlobalGameValues.Values.content.Fonts.TryGetValue("menu", out font))
            {
                throw new System.ArgumentException("Couldn't find font");
            }
            Texture2D health;
            if (!GlobalGameValues.Values.content.Textures.TryGetValue("health", out health))
            {
                throw new System.ArgumentException("Couldn't find health texture");
            }
            string text = GlobalGameValues.Values.GlobalStrings.getValue("plasma") + ": ";
            HUD.Add(new Label(text, new Vector2(885, 10), game.spriteBatch, font));
            Weaponbar plasmaBar = new Weaponbar(0, new Vector2(1050, 15), game.spriteBatch);
            HUD.Add(plasmaBar);
            text = GlobalGameValues.Values.GlobalStrings.getValue("laser") + ": ";
            HUD.Add(new Label(text, new Vector2(885, 10 + font.LineSpacing), game.spriteBatch, font));
            Weaponbar laserBar = new Weaponbar(0, new Vector2(1050, 15 + font.LineSpacing), game.spriteBatch);
            HUD.Add(laserBar);
            text = GlobalGameValues.Values.GlobalStrings.getValue("missile") + ": ";
            HUD.Add(new Label(text, new Vector2(885, 10 + 2 * font.LineSpacing), game.spriteBatch, font));
            Weaponbar missileBar = new Weaponbar(0, new Vector2(1050, 15 + 2 * font.LineSpacing), game.spriteBatch);
            HUD.Add(missileBar);
            text = GlobalGameValues.Values.GlobalStrings.getValue("mode") + ": ";
            HUD.Add(new Label(text, new Vector2(885, 10 + 3.5f * font.LineSpacing), game.spriteBatch, font));
            Label modeLabel = new Label("1", new Vector2(1050, 10 + 3.5f * font.LineSpacing), game.spriteBatch, font);
            HUD.Add(modeLabel);
            text = GlobalGameValues.Values.GlobalStrings.getValue("hp");
            Vector2 size = font.MeasureString(text);
            HUD.Add(new Label(text, new Vector2(870 + 125 - size.X / 2, 580), game.spriteBatch, font));
            Healthbar healthBar = new Healthbar(new Rectangle((int)(870 + 125 - size.X / 2), 380, (int)size.X, 200), health, 100, new Vector2(870 + 125 - size.X / 2, 380), game.spriteBatch, 100);
            HUD.Add(healthBar);
            Label scoreLabel = new Label("0", new Vector2(33, 580), game.spriteBatch, font);
            HUD.Add(scoreLabel);
            GlobalGameClasses.GlobalGameValues.Values.score.AddComponent(scoreLabel);
            GlobalGameClasses.GlobalGameValues.Values.score.value = 0;
            World world = new World(game.acHandler, drawableList, HUD, script);
            world.GameEnd += new Eventhandler.GameEndEventHandler(game.OnGameEnd);

            //Create playership and drone
            Matrix worldMatrix_Player = Matrix.CreateScale(0.025f) * Matrix.CreateWorld(new Vector3(50, GlobalGameValues.GAMEFIELD_HEIGHT, -100), Vector3.Backward, Vector3.Up);
            Matrix worldMatrix_Drone = Matrix.CreateScale(0.035f) * Matrix.CreateWorld(new Vector3(110, GlobalGameValues.GAMEFIELD_HEIGHT, -140), Vector3.Backward, Vector3.Up);
            SpecialEffectsAircraft aircraft_player = SpecialEffectsAircraft.GET_PLAYER_SHIP(worldMatrix_Player);
            healthBar.maxHealth = aircraft_player.maxHealth;

            aircraft_player.addWeaponBar(plasmaBar, Weapon.WeaponType.Plasma);
            aircraft_player.addWeaponBar(missileBar, Weapon.WeaponType.Missile);
            aircraft_player.addWeaponBar(laserBar, Weapon.WeaponType.Laser);
            aircraft_player.addHealthBar(healthBar);
            SpecialEffectsAircraft aircraft_drone = SpecialEffectsAircraft.GET_DRONE(worldMatrix_Drone);
            PlayerControlledAircraft controller = new PlayerControlledAircraft(aircraft_player);
            AIControlledAircraft_Drone droneControl = new AIControlledAircraft_Drone(aircraft_player, aircraft_drone);
            droneControl.mode.AddComponent(modeLabel);
            aircraft_player.controller = controller;
            aircraft_drone.controller = droneControl;
            aircraft_player.speed = 1.5f;
            aircraft_drone.speed = 1f;
            aircraft_player.aircraftAttributes.Add(Aircraft.AircraftAttributes.Armoured);
            aircraft_player.aircraftAttributes.Add(Aircraft.AircraftAttributes.Triggers_Defeat);
            aircraft_player.actorAttributes.Add(Actor.ActorAttributes.Floating);
            aircraft_drone.aircraftAttributes.Add(Aircraft.AircraftAttributes.Indestructible_Collissions);
            aircraft_drone.aircraftAttributes.Add(Aircraft.AircraftAttributes.Indestructible_Projectiles);
            aircraft_drone.actorAttributes.Add(Actor.ActorAttributes.Floating);
            aircraft_drone.aircraftAttributes.Add(Aircraft.AircraftAttributes.Transparent_Aircraft);
            aircraft_player.Collide += new Eventhandler.CollideEventHandler(game.acHandler.OnCollide);
            aircraft_player.owner = Owner.PLAYER;
            aircraft_drone.owner = Owner.PLAYER;
            //Add playership and drone to world
            aircraft_player.world = world;
            aircraft_drone.world = world;
            world.addActor(aircraft_player, false);
            world.addActor(aircraft_drone);

            Effect shader_actor = game.Content.Load<Effect>("light_MultiLighting");
            Effect shader_shadowMap = game.Content.Load<Effect>("light_ShadowMapping");
            Effect shader_terrain = game.Content.Load<Effect>("terrainShader");
            Effect shader_Explosion = game.Content.Load<Effect>("EffectExplosion");
            Effect shader_ParticleEffect = game.Content.Load<Effect>("ParticleEffect");
            Effect shader_shockwave = game.Content.Load<Effect>("distortionEffect");

            Camera camera = new Camera(new Vector3(150, 230, 0), new Vector3(150, 0, -(float)System.Math.Tan(MathHelper.ToRadians(22.5f)) * 250), -0.5f);

            GlobalLight globalLight = GlobalLight.CreateGlobalLight();
            View view = new View(drawableList, shader_actor, camera, HUD, shader_shadowMap, game.spriteBatch, game.terrain, shader_terrain, globalLight, "HUDBackground", shader_Explosion, shader_ParticleEffect, shader_shockwave);
            GameMode gameMode = new GameMode(null, view, world);

            return gameMode;
        }

        public MenuMode createAchievementMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("unlockedAchievements");
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X, 315 - size.Y / 2f - 6 * font.LineSpacing - 6 * 20);
            Label label = new Label(text, pos, game.spriteBatch, font);
            components.Add(label);
            int i = -4;
            foreach (Achievement a in game.currentAccount.achievements)
            {
                size = font.MeasureString(a.name);
                Vector2 posB = new Vector2(pos.X + 40, 315 - size.Y / 2f + i * font.LineSpacing + i * 30);
                label = new Label(a.name, posB, game.spriteBatch, font);
                components.Add(label);
                size = font.MeasureString(a.description);
                posB = new Vector2(posB.X + 20, posB.Y + font.LineSpacing);
                label = new Label(a.description, posB, game.spriteBatch, font);
                components.Add(label);
                i += 1;
            }
            text = GlobalGameValues.Values.GlobalStrings.getValue("back");
            Vector2 sizeB = font.MeasureString(text);
            Vector2 posC = new Vector2(560 - sizeB.X / 2f, 580);
            Button button = new Button(new Rectangle((int)posC.X - 5, (int)posC.Y - 5, (int)sizeB.X + 10, (int)sizeB.Y + 10), text, posC, game.spriteBatch, font, SirianGame.Modes.Main, SirianGame.Modes.Achievement);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public MenuMode createPauseMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("continueGame");
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 2 * font.LineSpacing - 2 * 20);
            Button button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.CurrentGame, SirianGame.Modes.Pause);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("restartGame");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 1 * font.LineSpacing - 1 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.NewGame, SirianGame.Modes.Pause);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("options");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 0 * font.LineSpacing - 0 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.PauseOption, SirianGame.Modes.Pause);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("endGame");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + 1 * font.LineSpacing + 1 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Main, SirianGame.Modes.Pause);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public MenuMode createDifficultyMenu(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("easy");
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 2 * font.LineSpacing - 2 * 20);
            Button button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.NewGame, SirianGame.Modes.Difficulty);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("medium");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 1 * font.LineSpacing - 1 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.NewGame, SirianGame.Modes.Difficulty);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("hard");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f - 0 * font.LineSpacing - 0 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.NewGame, SirianGame.Modes.Difficulty);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            text = GlobalGameValues.Values.GlobalStrings.getValue("veryHard");
            size = font.MeasureString(text);
            pos = new Vector2(560 - size.X / 2f, 315 - size.Y / 2f + 1 * font.LineSpacing + 1 * 20);
            button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.NewGame, SirianGame.Modes.Difficulty);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }

        public MenuMode createEndScreen(Texture2D background, SpriteFont font)
        {
            List<InterfaceComponent> components = new List<InterfaceComponent>();
            string text = GlobalGameValues.Values.GlobalStrings.getValue("back");
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(0 - size.X - 10, 0);
            Button button = new Button(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, (int)size.X + 10, (int)size.Y + 10), text, pos, game.spriteBatch, font, SirianGame.Modes.Highscore, SirianGame.Modes.EndScreen);
            button.buttonClick += new GlobalGameClasses.Eventhandler.ButtonEventHandler(game.OnButtonClick);
            components.Add(button);
            return new MenuMode(background, components, Color.Yellow, Color.White, game.spriteBatch);
        }
    }
}
